<?php
namespace BP\Sys;
require_once("BP/En/Map.php");
require_once("BP/Web/WebUser.php");
class GroupField extends EntityOID {
	public $IsUse;	// boolean
	private function __init() { // default class members
		$this->IsUse =  FALSE ;
	}
	public function getHisUAC () 
	{
		$uac = new UAC();
		if (($WebUser->getNo()->equals("admin") || $WebUser->getIsAdmin()))
		{
			$uac->IsDelete =  TRUE ;
			$uac->IsInsert =  FALSE ;
			$uac->IsUpdate =  TRUE ;
			return $uac;
		}
		$uac->Readonly();
		$uac->IsView =  FALSE ;
		return $uac;
	}
	public function getFrmID () 
	{
		return $this->GetValStrByKey(GroupFieldAttr::$FrmID);
	}
	public function setFrmID ($value) // [String value]
	{
		$this->SetValByKey(GroupFieldAttr::$FrmID, $value);
	}
	public function getEnName () 
	{
		return $this->GetValStrByKey(GroupFieldAttr::$FrmID);
	}
	public function setEnName ($value) // [String value]
	{
		$this->SetValByKey(GroupFieldAttr::$FrmID, $value);
	}
	public function getLab () 
	{
		return $this->GetValStrByKey(GroupFieldAttr::$Lab);
	}
	public function setLab ($value) // [String value]
	{
		$this->SetValByKey(GroupFieldAttr::$Lab, $value);
	}
	public function getIdx () 
	{
		return $this->GetValIntByKey(GroupFieldAttr::$Idx);
	}
	public function setIdx ($value) // [int value]
	{
		$this->SetValByKey(GroupFieldAttr::$Idx, $value);
	}
	public function getCtrlType () 
	{
		return $this->GetValStrByKey(GroupFieldAttr::$CtrlType);
	}
	public function setCtrlType ($value) // [String value]
	{
		$this->SetValByKey(GroupFieldAttr::$CtrlType, $value);
	}
	public function getCtrlID () 
	{
		return $this->GetValStrByKey(GroupFieldAttr::$CtrlID);
	}
	public function setCtrlID ($value) // [String value]
	{
		$this->SetValByKey(GroupFieldAttr::$CtrlID, $value);
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->__init();
		return $me;
	}
	public static function constructor__I ($oid) // [int oid]
	{
		$me = new self();
		$me->__init();
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("Sys_GroupField", "傻瓜表单分组");
		$map->Java_SetDepositaryOfEntity($Depositary->None);
		$map->Java_SetDepositaryOfMap($Depositary->Application);
		$map->Java_SetEnType($EnType->Sys);
		$map->AddTBIntPKOID();
		$map->AddTBString(GroupFieldAttr::$Lab, NULL, "标签",  TRUE ,  FALSE , 0, 500, 20,  TRUE );
		$map->AddTBString(GroupFieldAttr::$FrmID, NULL, "表单ID",  TRUE ,  TRUE , 0, 200, 20);
		$map->AddTBString(GroupFieldAttr::$CtrlType, NULL, "控件类型",  TRUE ,  TRUE , 0, 50, 20);
		$map->AddTBString(GroupFieldAttr::$CtrlID, NULL, "控件ID",  TRUE ,  TRUE , 0, 500, 20);
		$map->AddTBInt(GroupFieldAttr::$Idx, 99, "顺序�?",  TRUE ,  FALSE );
		$map->AddTBString(MapAttrAttr::$GUID, NULL, "GUID",  TRUE ,  TRUE , 0, 128, 20,  TRUE );
		$map->AddTBAtParas(3000);
		$rm = new RefMethod();
		$rm = new RefMethod();
		$rm->Title = "删除隶属分组的字�?";
		$rm->Warning = "您确定要删除该分组下的所有字段吗�?";
		$rm->ClassMethodName = ($this . ".DoDelAllField");
		$rm->refMethodType = $RefMethodType->Func;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "调整字段顺序";
		$rm->ClassMethodName = ($this . ".DoGroupFieldIdx");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	public function AddGroup () 
	{
		$this->InsertAsNew();
		return "执行成功.";
	}
	public function DoDelAllField () 
	{
		$sql = (((("DELETE FROM Sys_MapAttr WHERE FK_MapData='" . $this->getFrmID()) . "' AND GroupID=") . $this->getOID()) . " AND KeyOfEn NOT IN ('OID','RDT','REC','RefPK','FID')");
		$i =DBAccess::RunSQL($sql);
		return (("删除字段{" . $i) . "}个，被删除成�?.");
	}
	public function DoGroupFieldIdx () 
	{
		return ((("../../Admin/FoolFormDesigner/GroupFieldIdx.htm?FrmID=" . $this->getFrmID()) . "&GroupField=") . $this->getOID());
	}
	protected function beforeUpdate () 
	{
		$sql = ((("UPDATE Sys_GroupField SET LAB='" . $this->getLab()) . "' WHERE OID=") . $this->getOID());
		DBAccess::RunSQL($sql);
		return parent->beforeUpdate();
	}
	public function DoDown () 
	{
		$this->DoOrderDown(GroupFieldAttr::$FrmID, $this->getFrmID(), GroupFieldAttr::$Idx);
		return "执行成功";
	}
	public function DoUp () 
	{
		$this->DoOrderUp(GroupFieldAttr::$FrmID, $this->getFrmID(), GroupFieldAttr::$Idx);
		return "执行成功";
	}
	protected function beforeInsert () 
	{
		try 
		{
			$sql = (((("SELECT MAX(IDX) FROM " . $this->getEnMap()->getPhysicsTable()) . " WHERE FrmID='") . $this->getFrmID()) . "'");
			$this->setIdx((DBAccess->RunSQLReturnValInt($sql, 0) + 1));
		}
		catch (\Exception $e)
		{
			$this->setIdx(1);
		}
		return parent->beforeInsert();
	}
}
?>
